/**
 * 
 */
package com.arx.damages;

import com.dalonedrau.opengl.Vector3;

/**
 * @author Donald
 */
public final class DamageInfo {
	private short	active;
	/** damage area type. */
	private long	area;
	private float	damages;
	/** in milliseconds, -1 for apply once, else damage *=framediff. */
	private long	duration;
	private short[]	except	= new short[10];
	private boolean	exist	= false;
	/** damages flags. */
	private long	flags;
	private long	lastupd;
	private Vector3	pos;
	private float	radius;
	/** io index or -1 for player. */
	private long	source;
	/** slowdown, paralysis... */
	private long	special;
	/** for io localised immunities or any other customization. */
	private long	special_ID;
	private long	start_time;
	/** damages type. */
	private long	type;
	/** Clears all flags. */
	public void clearFlags() {
		flags = 0;
	}
	public boolean exists() {
		return exist;
	}
	public short getActive() {
		return active;
	}
	public long getArea() {
		return area;
	}
	public long getDuration() {
		return duration;
	}
	public short getException(final int index) {
		short val = -1;
		if (index >= 0 && index < except.length) {
			val = except[index];
		}
		return val;
	}
	public long getLastupd() {
		return lastupd;
	}
	public float getRadius() {
		return radius;
	}
	public long getSpecial() {
		return special;
	}
	public long getSpecial_ID() {
		return special_ID;
	}
	public long getStart_time() {
		return start_time;
	}
	public long getType() {
		return type;
	}
	/**
	 * Determines if the {@link DamageInfo} has a specific flag set.
	 * @param flag the flag
	 * @return true if the object has the flag set; false otherwise
	 */
	public boolean hasFlag(final int flag) {
		return (flags & flag) == flag;
	}
	/**
	 * Removes a flag.
	 * @param flag the flag
	 */
	public void removeFlag(final int flag) {
		flags = flags & ~flag;
	}
	public void setActive(final short active) {
		this.active = active;
	}
	public void setArea(final long area) {
		this.area = area;
	}
	public void setDuration(final long duration) {
		this.duration = duration;
	}
	public void setException(final int index, final short val) {
		if (index >= 0 && index < except.length) {
			except[index] = val;
		}
	}
	public void setExists(final boolean val) {
		exist = val;
	}
	/**
	 * Sets a flag.
	 * @param flag the flag
	 */
	public void setFlag(final int flag) {
		if ((flags & flag) != flag) {
			flags += flag;
		}
	}
	public void setLastupd(final long lastupd) {
		this.lastupd = lastupd;
	}
	public void setRadius(final float radius) {
		this.radius = radius;
	}
	public void setSpecial(final long special) {
		this.special = special;
	}
	public void setSpecial_ID(final long special_ID) {
		this.special_ID = special_ID;
	}
	public void setStart_time(final long start_time) {
		this.start_time = start_time;
	}
	public void setType(final long type) {
		this.type = type;
	}
}
